Skip to content

kernel/user partition, Phase 4 part 7: CI check against <sof/kernel/...> in user-space code - #11489

Draft
lgirdwood wants to merge 11 commits into
thesofproject:mainfrom
lgirdwood:kernel-user/phase4g
Draft

lgirdwood wants to merge 11 commits into
thesofproject:mainfrom
lgirdwood:kernel-user/phase4g

Conversation

@lgirdwood

Copy link
Copy Markdown
Member

Phase 4 of #11306 (kernel / user-space partition), seventh part: enforce the "no <sof/kernel/...> in user-space code" rule on the source tree, as the issue plans ("add a checkpatch rule against <sof/kernel/ in user dirs"). SOF's CI does not run checkpatch, so this is a mode of the include checker that runs in the codestyle workflow instead.

Based on #11487. Only the last four commits are new.

Why

The build-based include check (#11464) only sees what the CI configurations compile. Since #11487, kernel-only headers in src/kernel/include are included as <sof/kernel/...>, so a kernel-only include is visible in the source. That makes a source-tree check cheap and exact:

  • it runs without building anything, so a pull request gets the result quickly;
  • it covers files that no CI configuration compiles.

Patches

  1. debug: remove src/debug/panic.c, the XTOS panic handler. Nothing builds it since the XTOS build rules were removed in e68dfe9, and the host library has its own panic.c. The source check found it, because it includes <sof/kernel/platform.h>.
  2. scripts: kernel_user_partition: classify the legacy LL scheduling domains (DMA single and multi channel, the Zephyr DMA domain, and the XTOS LL scheduler that ACP 6.0 still builds) as kernel sources.
    • They set up interrupts and timers, and include <sof/kernel/platform.h>.
    • Like the legacy host and DAI drivers, they go when the remaining platforms move to the Zephyr native drivers.
  3. scripts: check_kernel_includes: add a --sources mode, which checks the source tree for <sof/kernel/...> includes.
    • What it checks: user-space sources, and the user-space headers listed in a new [user-headers] manifest section (src/include and src/platform, apart from the kernel-only headers still there).
    • No baseline: no user-space code includes them today.
    • Strict mode: --strict fails when one is added.
  4. ci: codestyle: run check_kernel_includes.py --sources --strict in a new kernel-includes job, and describe it in the src/kernel README.

Install rules

The issue's item "install rules install only the user include set" needs no change. Only the host library installs headers: it installs the sof_public_headers include directories, and #11487 put src/kernel/include on sof_options instead. So the kernel-only headers are not installed. The host platform headers still are, but the host build is not partitioned, and its users, the testbench and plugin, need them.

Functional change

None.

Testing

  • Source check:
    • passes on the tree;
    • with a <sof/kernel/...> include added to a user-space source (volume.c) and to a user-space header (component.h), it reports both and fails.
  • Build check: with --strict, it still passes for the 12 CI build configurations and the other configurations below, with the same 16 baseline sources.
  • Workflow: codestyle.yml passes yamllint with the workflow's settings.
  • Per commit, compared with kernel/user partition, Phase 4 part 6: move kernel-only headers to sof/kernel #11487:
    • Builds: tgl, tgl-h, mtl, lnl, ptl, wcl, nvl, imx8, imx8x, imx8m, imx8m_cm7, imx8ulp, imx95 and qemu_xtensa, and the extra CI configurations:
      • native_sim IPC3/IPC4 stub builds;
      • imx93 64-bit;
      • PTL with each userspace overlay;
      • PTL with CONFIG_SOF_USERSPACE_PROXY=n;
      • PTL and MTL with os_linux_overlay.conf;llext_relocatable.conf;
      • PTL and TGL with app/debug_stream_overlay.conf, and PTL with that overlay and user-space LL.
    • Comparisons: objects, LLEXT modules and firmware images (sections, symbols, SYS_INIT() order), and the per-function disassembly. No object changes at any commit. The only image difference is sof_init() on imx8m_cm7, imx93 and imx95, which embeds the git hash.
    • Signing: rimage runs for every Intel platform, and the generated configs are unchanged.
    • ZTest: the unit tests pass, run as in CI (20 of 20 configurations).
    • Host: the host library and the cmocka unit tests build and pass.
  • At the tip:
    • the testbench and the tools pass;
    • the host library and the cmocka unit tests pass for all nine defconfigs and the library config;
    • the platforms that already fail on main (acp_6_0, acp_7_0, acp_7_x, mt8186, mt8188, mt8195, mt8196, mt8365) have unchanged error sets.

All of the above was run on #11487, on afa3820 (main).

🤖 Generated with Claude Code

lrgirdwo and others added 11 commits November 18, 2026 13:39
Phase 4 of the kernel / user-space partition moves the kernel-only
headers to src/kernel/include/sof/kernel, included as
<sof/kernel/...>, so that kernel-only includes are visible in the
source and the headers can later be kept off the user-space include
path.

Add the directory to the include path of the firmware (the SOF
interface library that sof_kernel and modules_sof use, so not the
LLEXT modules), of the host library, of the testbench and the
topology parser, and of the ZTest unit tests that build kernel
sources. The include checker
treats everything below it as kernel-only. The headers move in the
following commits.

No functional change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Liam Girdwood <[email protected]>
sof/platform.h declares the platform init, boot and context save
functions and includes the platform definitions. Only kernel code
includes it. Move it to src/kernel/include and include it as
<sof/kernel/platform.h>, and update the platform headers that name it
in their include guard errors.

No functional change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Liam Girdwood <[email protected]>
sof/ipc/driver.h is the interface between the IPC core and the
platform IPC driver: message transmit and receive, the IPC task and
the host page tables. Only kernel code, and the host testbench and
unit tests built with the kernel code, include it. Move it to
src/kernel/include and include it as <sof/kernel/ipc/driver.h>.

No functional change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Liam Girdwood <[email protected]>
sof/llext_manager.h declares the LLEXT loader and its dependency
handling, which only the kernel library manager code uses. Move it to
src/kernel/include and include it as <sof/kernel/llext_manager.h>.

No functional change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Liam Girdwood <[email protected]>
The headers in sof/drivers describe the AMD, MediaTek and i.MX DAI
and DMA drivers, the i.MX messaging unit, the SSP and the interrupt
map. Only kernel code includes them. Move them to src/kernel/include
and include them as <sof/kernel/drivers/...>, and update the code
owner entries.

dmic.h and pmc.h are not used anymore and stay for now.

No functional change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Liam Girdwood <[email protected]>
sof/lib/regions_mm.h (the virtual memory heaps) and sof/lib/vpage.h
(the virtual page allocator) are the interfaces of kernel memory
management code. Only kernel code and its tests include them. Move
them to src/kernel/include and include them as
<sof/kernel/lib/regions_mm.h> and <sof/kernel/lib/vpage.h>.

No functional change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Liam Girdwood <[email protected]>
Nothing includes sof/drivers/dmic.h, the definitions of the removed
SOF DMIC driver, or sof/drivers/pmc.h and the host platform pmc.h
that it wraps. Remove them, with their code owner and include checker
entries, instead of moving them to the kernel headers.

No functional change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Liam Girdwood <[email protected]>
src/debug/panic.c is the XTOS panic handler. Its build rules went with
the XTOS support in commit e68dfe9 ("build: remove XTOS-specific
sections from cmake lists"), and the host library has its own
panic.c, so nothing builds it. Remove it.

No functional change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Liam Girdwood <[email protected]>
The DMA single and multi channel and the Zephyr DMA LL scheduling
domains, and the XTOS LL scheduler that ACP 6.0 still builds, set up
interrupts and timers and include sof/kernel/platform.h. Like the
legacy host and DAI drivers, they are kernel code that goes when the
remaining platforms move to the Zephyr native drivers. Classify them
as kernel sources.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Liam Girdwood <[email protected]>
The kernel-only headers are moving to src/kernel/include, included as
<sof/kernel/...>. Add a --sources mode that checks the source tree,
without build directories, for such includes in user-space sources and
in the user-space headers listed in the new [user-headers] manifest
section: src/include and src/platform, apart from the kernel-only
headers that are still there.

This is the "no <sof/kernel/ in user-space code" rule of thesofproject#11306. It
also covers code that no checked build configuration compiles, and
there is nothing to baseline: no user-space code includes them today.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Liam Girdwood <[email protected]>
Run the include checker on the source tree in the codestyle workflow,
so that a pull request that includes a header from src/kernel/include
in user-space code fails without waiting for the firmware builds, and
also when no CI configuration compiles the file. Describe it in the
src/kernel README.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Liam Girdwood <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants